package annotion.example.hss_fst.baselib.fragments;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.meetme.android.multistateview.MultiStateView;

import annotion.example.hss_fst.baselib.R;

/**
 * @author 黄赛赛
 * @version V1.0
 * @Title: ${file_name}
 * @Package ${package_name}
 * @Description: ${todo}()
 * @date 2016/9/21 11:26
 */
public class MultipleStateFragment extends Fragment {
    View root_view;
    MultiStateView msv;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        root_view =  inflater.inflate(R.layout.fragment_multiplestate,
                container, false);
        return  root_view;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        msv = (MultiStateView) root_view.findViewById(R.id.msv);
        root_view.findViewById(R.id.loding).setOnClickListener(clickListener);
        root_view.findViewById(R.id.net_error).setOnClickListener(clickListener);
        root_view.findViewById(R.id.general_error).setOnClickListener(clickListener);
        root_view.findViewById(R.id.empty).setOnClickListener(clickListener);
        root_view.findViewById(R.id.content).setOnClickListener(clickListener);

    }

    View.OnClickListener clickListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            switch (v.getId()){
                case R.id.loding:
                    msv.setState(MultiStateView.ContentState.LOADING);
                    break;
                case R.id.net_error:
                    msv.setState(MultiStateView.ContentState.ERROR_NETWORK);

                    break;
                case R.id.general_error:
                    msv.setState(MultiStateView.ContentState.ERROR_GENERAL);

                    break;
                case R.id.empty:
                    msv.setState(MultiStateView.ContentState.EMPTY);

                    break;
                case R.id.content:
                    msv.setState(MultiStateView.ContentState.CONTENT);

                    break;


            }
        }
    };
}
